package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.vo.EnterpriseInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GwEnterpriseInfo;
import com.ruoyi.system.service.IGwEnterpriseInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业信息管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-13
 */
@Api(description = "企业信息管理（平台运营管理共用）")
@RestController
@RequestMapping("/system/enterpriseInfo")
public class GwEnterpriseInfoController extends BaseController
{
    @Autowired
    private IGwEnterpriseInfoService gwEnterpriseInfoService;


    @GetMapping("/list")
    public TableDataInfo list(GwEnterpriseInfo gwEnterpriseInfo)
    {
        startPage();
        List<GwEnterpriseInfo> list = gwEnterpriseInfoService.selectGwEnterpriseInfoList(gwEnterpriseInfo);
        return getDataTable(list);
    }

    /**
     * 平台运营管理-列表查询
     */
    @ApiOperation("平台运营管理使用-列表查询")
    @PreAuthorize("@ss.hasPermi('system:enterpriseInfo:list')")
    @GetMapping("/enterpriseInfoList")
    public TableDataInfo enterpriseInfoList(GwEnterpriseInfo gwEnterpriseInfo)
    {
        startPage();
        List<EnterpriseInfoVO> list = gwEnterpriseInfoService.enterpriseInfoList(gwEnterpriseInfo);
        return getDataTable(list);
    }

    /**
     * 查询我得企业信息
     */
    @GetMapping(value = "/getMyEnterpriseInfo")
    public AjaxResult getMyEnterpriseInfo()
    {
        GwEnterpriseInfo  gwEnterpriseInfo = gwEnterpriseInfoService.getMyEnterpriseInfo();
        return success(gwEnterpriseInfo);
    }

    /**
     * 导出企业信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:enterpriseInfo:export')")
    @Log(title = "企业信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwEnterpriseInfo gwEnterpriseInfo)
    {
        List<GwEnterpriseInfo> list = gwEnterpriseInfoService.selectGwEnterpriseInfoList(gwEnterpriseInfo);
        ExcelUtil<GwEnterpriseInfo> util = new ExcelUtil<GwEnterpriseInfo>(GwEnterpriseInfo.class);
        util.exportExcel(response, list, "企业信息管理数据");
    }

    /**
     * 获取企业信息管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:enterpriseInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gwEnterpriseInfoService.selectGwEnterpriseInfoById(id));
    }


//    @PreAuthorize("@ss.hasPermi('system:enterpriseInfo:add')")
    @Log(title = "企业信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GwEnterpriseInfo gwEnterpriseInfo)
    {
        return toAjax(gwEnterpriseInfoService.insertGwEnterpriseInfo(gwEnterpriseInfo));
    }

    /**
     * 新增企业信息管理--平台运营管理使用
     */
    @ApiOperation("平台运营管理使用-新增企业信息")
//    @PreAuthorize("@ss.hasPermi('system:enterpriseInfo:add')")
    @Log(title = "企业信息管理", businessType = BusinessType.INSERT)
    @PostMapping("/addEnterpriseInfo")
    public AjaxResult addEnterpriseInfo(@RequestBody GwEnterpriseInfo gwEnterpriseInfo)
    {
        return gwEnterpriseInfoService.addEnterpriseInfo(gwEnterpriseInfo);
    }

    /**
     * 修改企业信息管理--平台运营管理使用
     */
    @ApiOperation("平台运营管理使用-修改企业信息")
//    @PreAuthorize("@ss.hasPermi('system:enterpriseInfo:edit')")
    @Log(title = "企业信息管理", businessType = BusinessType.UPDATE)
    @PutMapping("/editEnterpriseInfo")
    public AjaxResult editEnterpriseInfo(@RequestBody GwEnterpriseInfo gwEnterpriseInfo)
    {
        return gwEnterpriseInfoService.editEnterpriseInfo(gwEnterpriseInfo);
    }

    /**
     * 修改企业信息管理
     */
//    @PreAuthorize("@ss.hasPermi('system:enterpriseInfo:edit')")
    @Log(title = "企业信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GwEnterpriseInfo gwEnterpriseInfo)
    {
        return toAjax(gwEnterpriseInfoService.updateGwEnterpriseInfo(gwEnterpriseInfo));
    }

    /**
     * 删除企业信息管理
     */
//    @PreAuthorize("@ss.hasPermi('system:enterpriseInfo:remove')")
    @Log(title = "企业信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gwEnterpriseInfoService.deleteGwEnterpriseInfoByIds(ids));
    }

    /**
     * 获取登录人信息
     * @Date 下午 1:04:44 2025/6/3
     * @return 结果
     **/
    @GetMapping(value = "/getLoginEnterpriseInfo")
    public AjaxResult getLoginEnterpriseInfo(){
        return gwEnterpriseInfoService.getLoginEnterpriseInfo();
    }
}
